home
***
CD-ROM
|
disk
|
FTP
|
other
***
search
/
Languguage OS 2
/
Languguage OS II Version 10-94 (Knowledge Media)(1994).ISO
/
language
/
pascal
/
pasos2.man
< prev
next >
Wrap
Text File
|
1994-10-29
|
16KB
|
449 lines
PASCAL compiler, ALPHA 0.2a release for OS/2 en DOS
Eindhoven, 9 june 1994
COMMAND
pc [options] <filename>.<ext>
pas [options] <filename>.<ext>
DESCRIPTION
This is the temporary manual page for
the pascal compiler frontend,
the pascal compiler.
In general it should be sufficient to use the compiler in the following
way:
'pc file.pas'
'pc otherfile.s'
'pc stillotherfile.o'
This creates a file 'file.exe' which can be executed.
The PASCAL 'version' implemented is as close to the standard level(0)
as possible. There are a few extentions, a few ommisions, plenty of
bugs, and some not yet implemented areas.
The actual code is transformed in several steps:
1) The user code is passed through the preprocessor.
2) Then 'pas' is used to transform the resulting PASCAL into
assembly.
3) The assembly code is used to create the objectcode for
the module.
4) Which is linked together with the PASCAL library, p.a,
and creates a the resulting executable.
To watch these steps, just add the -v switch to the pc command.
OPTIONS for pc
-v* Show command the frontend executes.
-Dname
-Dname=def Set definitions for the preprocessor.
-Uname Instruct the preprocessor to undefine 'name'.
-S Generate an assembly file and terminate
-c Generate an object file, but do not link.
-E Only run the preprocessor on the file, and write results to
standard ouput.
-o <file> Specify the file in which the result should be
written.
-h Runtime help information.
-Q Suppress the copyright info when pc starts
-x Generate a crossreference in <filename>.xrf
-G Generate GAS typical code and use GAS to assemble.
OPTIONS for pas
-v* Switch verbosity one level higher.
-h Runtime help information.
-x Generate a crossreference in <filename>.xrf
-G Generate GAS typical code and use GAS to assemble.
-d Debugging options.
abEePprsTt
Most of these switches are used for debugging the compiler
and of little use to a normal user.
a Insert numerous comments into the assembly
b* Give information on BackEnd selections
r List the tokens found by the scanner
p Show which rules are matched in the parser
i dump the identifier table to <filename>.ids
t/T* dump the AST/defs tree (or more Tree)
to <filename>.tre for AST trees
to <filename>.syt for defs-trees
s write a trace of the semantic evaluation
to <filename>.sem
P Dump the predefined environment.
e/E* List the environments on numerous ocassions
* indicates that a switch has levels, multiple specification
of the switch indicates "more" of that switch.
Capitals of those switches increment the debugging level
with five lowercases.
PREPROCESSING
The preprocessor knows about PASCAL like comments and should be able
to handle (*{}*) or {(**)} correctly.
It also knows the following "pragmas":
#include
#define
#undef
#if
#ifdef
#ifndef
#else
A pragma has to be a single line, unless the EOLN is escaped by a '\'
The '#'-mark has to be in the first position on the line.
ASSEMBLERS
NOTE: IMPORTANT.
This compiler does not include an assembler, but it does require one.
This forth release can only use:
GNU/GAS which can run on the EMX environment for DOS and OS2.
The current version of EMX used is emx-0.8h, be shure to use this
version. Otherwise get an upgrade.
(Note that for execution undr DOS a CO-processor is required.
The Pascal compiler uses floating point at some places.
This will be changed in the near future.)
If you have installed the EMX gnu compiler tools, you can use GNU/GAS
which is the default. If you have installed only the emx-runtime
environment installed you'll need to add some extra tools.
Install emxrt
emxdev
gnudev. (See the install.emx file)
These files are part of the EMX distribution which includes GNU/GCC.
DEBUGGING
Not much attention has (yet) been given to debugging and creating
debugging information. I debug the programs on assembly language level
using IBM's IPMD and GNU gdb.
You don't want to do this, unless you're familiar with the 386-code,
since no PASCAL code is included. And it can be mind boggling to find
out what is going on.
EXTENTIONS
Several extenstions have been implemented to make life a little easier.
Comments: A comment started by one version of the comments
starter, has to be terminated by the matching comment
close combination. They cannot be nested.
Thus the following are complete comments:
{(**)}, (*{}*). (*}*) {*)}
Not correct are:
{*), (*}, (*{*), {(*} or {(*{}*)}
Identifiers: Identifiers can contain '_' and '$' as valid characters.
if '_' of '$' is used first character then the
second character has to be one from the
set ['a'..'z','A'..'Z'].
Identifiers are case insensitive.
Declaration order The declaration order of constants, types,
variables and routines is not required. These
declaration blocks can be repeated multiple times in
any order. The only restriction is that pointer-type
definitions are teh only definitions that can refer to
types yet to be declared.
EXTERNAL Next to the 'FORWARD' directive for routines, is the
'EXTERNAL' directive available as an indication to the
compiler/assembler that code for this routine is to be
found elsewhere. The syntax equals that of a 'FORWARD'
definition.
CEXTERNAL Is used to link against routines available in the
C-libs. Currently the GNU/EMX convention is supported
for integers and reals, procedure and functions.
Again the definitions is equal to 'FORWARD'
definitions.
The C-compiler convention that names are prefixed by a
'_' is supported and thus routines names in PASCAL need
not start with a '_'.
Eg:
C: extern int atoi(char *);
PASCAL: string = array[1..8] of char;
FUNCTION atoi( s :string): integer;
CEXTERNAL;
CASE-statement The CASE-statement has been expanded with a default
clause. Both OTHERWISE and ELSE are recognised as
default selectors. This is the grammar for the
extention:
statement9a = 'CASE' expression 'OF' case_list case_default case_end.
case_default = <
/* A Microsoft extention */
case_default1 = 'OTHERWISE' statement .
case_default1a = ';' 'OTHERWISE' statement .
/* A Turbo Pascal extention */
case_default2 = 'ELSE' statement .
>.
MinInt Next to the constant MaxInt (2147483647) is also the
constant MinInt (-2147483648) available.
Reset, Rewrite
Assign To be able to interact with the filesystem, it is
possible to use the procedure
Reset (Var f: anyfile, s :string),
ReWrite(Var f: anyfile, s :string),
ASSIGN (Var f: anyfile, s :string),
an associate an external filename with an internal file.
A reset or rewrite without a filename specifier will
try to open a file with the name 'f'. If no such name
exists in Reset an error results. Rewrite creates the
file and writes to it.
MULTI MODULE COMPILATION
It is now possible to compile MODULEs which contain code fragments,
and need a PROGRAM module for execution. (One can also check the code
in the library.)
Syntax:
MODULE = 'module' <decls> 'begin' <code> 'end'. (1)
| 'module' <decls> 'end'. (2)
;
The <code> part in (1) is intended for initialising the preconditions
for the module.
NB: These codeparts are currently ignored! So one will have to call an
initialiser routine manually. (This will probably change in a next
release)
There is currently no supported way to use variables which are declared
in other modules, other than redeclaring them in every module and have
the linker resolve the linkages.
NOTE:
This also means that one cannot use the same identifier at the global
level in multiple places, without the "feature" that they share the
same location. (Global variables like 'i' are going to suffer most.)
For procedures and routines is the attribute 'EXTERNAL' available.
Eg.: 'Procedure SomeWhereElse(i;integer); EXTERNAL'
OMMISIONS
PACKED The keyword 'PACKED' is allowed in declarations but is
ignored. Using it does not give any allocation
advantages. The accompanying routines 'PACK' and
'UNPACK' are not implemented. They are recognised by
the scanner/parser.
CONFORMANT ARRAY Conformant arrays are not included with a PASCAL
level(0) implementation.
FEATURES
SET A set can be as big as 64K elements, and the
limits are -32768..32767.
NOT YET IMPLEMENTED
ROUTINES as parameters.
The PASCAL standard allows routines to passed a
parameters to other routines. The parser will recognise
the code but during semantic analysis the
constructions will be refused.
KNOWN BUGS
Dependant on your compiler history you will find that certain
compile-time checks are not enforced.
Other than some relaxed requirements and extentions, are there really
some bugs that should be brought to the attention of the
compiler-writer since they create too much freedom for erronous
programs.
Please report these ommisions.
The LIBRARY_PATH environment variable (also used by GCC) should not
contain more than one directory. This restriction will disapear in
near future.
When using reset/rewrite with one character names (eg. 'f'), the name
needs to be manually assigned and bigger than 1 character. Otherwise
compile-time errors will occur.
Eg.:
assign(f, 'ff');
rewrite(f);
BUGS
There should be a lot less bugs this time, they will be still around
though. That is why this version is still an ALPHA release.
There are several flaws in the code generation. And although many case
have been tested in isolation, complex situations can cause wrong code
to be generated.
Please report these to the author, so that they can be fixed.
(Or at least mentioned in the buglist)
The compiler is sometimes able to recognise the fact that it is in an
inconsistent state.
Then usually informational text is written to the screen.
This output, your input, and possibly the core dump, can be of help to
me. you can (E)mail me all parts involved. (Prefably stripped to the
smallest code-chunk which still exhibits the behaviour.)
These messages can look like:
"Houston, Code generation problem.
Program aborted."
Or:
"Houston, we've got a serious problem with the register
allocation.
Program aborted."
Or a large sequence of what looks like semi machine instructions.
Which means that yor programmed a program sequence which confuses the
codegenerator part of the compiler. This should not happen, so it is
a compiler bug. Please report this bug.
Sometimes it is possible to rewrite the expression or statement
causing the trouble. But you'll have to locate the cullpit.
The major reason for this is/was that I overlooked a stdroutine/type
combination.
On several places in the runtime library are tests on the outcome of
systemcalls. If they fail, a message with that regard is printed on
'stderr'. Note that this need not always be a error in the library.
It could also be due to incorrect use of the runtime library by the
program.
During execution, traps can occur. Usually this means that either
pointers or array accesses have been outside the current allowed space.
Eg:
core dumped
SYS1808:
The process has stopped. The software diagnostic
code (exception code) is 0005.
These could be compiler errors, but lately I haven't found many of
those that showed in this blunt way. Usually the compiler shows the
errors more 'secretly'.
DEFAULTS
Default heap size is set to 1 Mb, but can be changed by recompiling
the 'heaplib.p' code which is part of the runtime environment.
ENVIRONMENT
PASCAL for OS/2 was generated using Cocktail compiler tools,
and compiled using the EMX/GCC. The code generated by the PASCAL
compiler also works with the EMX system. So the runtime environment for
the compiler has to include the EMX runtime environment.
In 'install.emx' is documentation available on how to install the
EMX-run time system. A reduced release of required tools is available
in 'emxpc.zip'
For the installation of pasos2 check the readme.pc file.
The PASCAL compiler itself uses several environment variables:
TMP The location for intermediate files.
Note that this directory has to exist.
PASLOAD Specify the number of minutes the compiler
image shoul remain resident. This will speedup
future compiles.
PAS_INC This path will be included in the seachpath for
the preprocessor.
PASPP The preprocessor to use. Unless you want to
use another set it to paspp.
But the linker can use others as well:
LIB The path used by LINK386 for libraries.
PAS_LIB The path where additional libraries can be
found for the linker. (currently ignored)
LIBRARY_PATH GNU/GAS libraries need to go into the
directory given by this env-variable.
Note that the current implementation only
allows one directory to be specified in this
path.
RUNTIME LIBRARY
The source for the runtime library is included in the package. It is
the part which is least severly tested. It has several problem areas in
it, but for most programming it should work.
One is always free to go through the runtime library code and modify it
to fit ones own requirements. If these changes are usefull to others as
well I'd be more than willing to include them in a new release.
The area with most problems in INPUT from an interactive file (eg.:
input), since different pascal compilers have different kind of
behaviour. TurboPascal nowhere nearly complies with the standard, and
as such is it currently hard to mimic it's behaviour.
[ Unless ofcourse, you are of the opinion that TurboPascal is the
standard :-( ]
FILES
.pas .p pascal source files
.inc .hp .hs assembler or pascal include files
.i pascal preprocessed files
.asm .s .S assembler sources
.obj MASM/ML object files (not supported)
.o GNU/GAS object files
.lib .a Library files
/tmp/pc???? Temporary files
ORIGINAL SOURCE
The most current release of this compiler should always be available
from:
ftp.eb.ele.tue.nl:/pub/src/pascal/pasos2?.zip
or:
ftp.cdrom.com:/os2/2_x/program/pasos2?.zip
where '?' represents the most recent version.
Sources of PC and components other than the GNU stuff are not (yet)
available.
EMX
EMX is available from:
ftp.eb.ele.tue.nl:/pub/pc/emx-0.8?
And a lot of sites much more near you.
ftp.cdrom.com:/os2/2_x/unix/emx08?
SEE ALSO
Kathleen Jensen and Niklaus Wirth.
Pascal User and Reference Manual
Springer Verlag, second edition, 1974.
British Standards Institution.
Specification fo computer programming language PASCAL, 1984.
ISO 7185 / BS 6192.
Willem Jan Withagen
A flexible frontend for a PASCAL compiler
Technical report Eindhoven University of technology
ftp: ftp.eb.ele.tue.nl:/pub/src/pascal/frontend.*
AUTHOR
Willem Jan Withagen. phone: +31-(0)40-473401
Eindhoven University of Technology fax: +31-(0)40-466033
Room 10.35 Email: wjw@eb.ele.tue.nl
PO Box 513
5600 MB Eindhoven
The Netherlands
Willem Jan Withagen. phone: +31-(0)40-511979
Martin Luther Kingstraat 48 fax: +31-(0)40-526825
5653 MG Eindhoven Email: wjw@wjw.iaehv.nl
The Netherlands